package cn.gy.gift.fallback;

import cn.gy.gift.client.LoginUserClient;
import cn.gy.gift.domain.LoginUser;
import cn.gy.gift.enums.SystemErrorCode;
import cn.gy.gift.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginUserFallback implements FallbackFactory<LoginUserClient> {
    @Override
    public LoginUserClient create(Throwable throwable) {
        throwable.printStackTrace();

        return new LoginUserClient() {
            @Override
            public AjaxResult addOrUpdate(LoginUser loginUser) {
                return AjaxResult.error(SystemErrorCode.RESPONSE_CODE_400500);
            }
        };
    }
}
